package com.jkdz.spyke.rs
{
	import com.jkgh.remedy.core.client.*;
	import flash.utils.ByteArray;
	import flash.net.Socket;

	public class SpykeRoomProxy implements SpykeRoom
	{
		public var remoteeID:int;
		protected var connection:RemedyClientServerConnection;

		public function SpykeRoomProxy(remoteeID:int, connection:RemedyClientServerConnection)
		{
			this.remoteeID = remoteeID;
			this.connection = connection;
		}

		public function registerListener(a:SpykeRoomListener):void
		{
			connection.performRun(remoteeID, function(connection:RemedyClientServerConnection):void {

				RemedyCodec.writeMethodID(connection.getSocket(), 51);
				RemedyMOClassManager.INSTANCE.writeWithGraph(a, connection, new Vector.<Object>());

			});
		}

		public function getAllWidgets(onReturn:Function/*Vector.<SpykeWidget>*/):void
		{
			connection.performCall(remoteeID, function(connection:RemedyClientServerConnection):void {

				RemedyCodec.writeMethodID(connection.getSocket(), 50);

			}, new RemedyFunctionSpecification(onReturn, RemedyArrayClassManager.forType(65)));
		}
	}
}
